home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Visual Basic Source Code
/
Visual Basic Source Code.iso
/
vbsource
/
unload1a
/
module1.bas
< prev
next >
Wrap
BASIC Source File
|
1999-10-21
|
3KB
|
52 lines
Attribute VB_Name = "Module1"
Option Explicit
Private Declare Function GetWindowDC Lib "user32" ( _
ByVal hwnd As Long) As Long
Private Declare Function GetDesktopWindow Lib "user32" () As Long
Private Declare Function GetDC Lib "user32" (ByVal hwnd As Long) As Long
Private Declare Function BitBlt Lib "GDI32" (ByVal hDestDC As Long, _
ByVal X As Long, ByVal Y As Long, ByVal nWidth As Long, _
ByVal nHeight As Long, ByVal hSrcDC As Long, _
ByVal XSrc As Long, ByVal YSrc As Long, ByVal dwRop As Long) As Long
Private Declare Function ReleaseDC Lib "user32" (ByVal hwnd As Long, _
ByVal hDC As Long) As Long
Sub DoIt()
Dim hDC As Long, hwnd As Long, l As Long, t As Long, hw As Long, hh As Long, i As Integer
Dim hhp As Long, hwp As Long, tppx As Long, tppy As Long
tppy = Screen.TwipsPerPixelY ' get current twip/pixel conversion value
tppx = Screen.TwipsPerPixelX ' get current twip/pixel conversion value
With Form1
l = .Left \ tppx ' Convert form1 left to pixels
t = .Top \ tppy ' convert form1 top to pixels
hh = .Height \ 2 ' get half-height
hw = .Width \ 2 ' get half-width (not half-wit!)
f1.Move .Left, .Top, hw, hh
f2.Move .Left + hw, .Top, hw, hh
f3.Move .Left, .Top + hh, hw, hh
f4.Move .Left + hw, .Top + hh, hw, hh
End With
hwnd = GetDesktopWindow() ' get the Window handle for the desktop window
hDC = GetWindowDC(hwnd) ' get a Device Context for the desktop window
hhp = hh \ tppy ' get half-height-in-pixels
hwp = hw \ tppx ' get half-width-in-pixels
BitBlt f1.hDC, 0, 0, hwp, hhp, hDC, l, t, vbSrcCopy ' copy Upper Left qtr
BitBlt f2.hDC, 0, 0, hwp, hhp, hDC, l + hwp, t, vbSrcCopy ' copy Upper Right qtr
BitBlt f3.hDC, 0, 0, hwp, hhp, hDC, l, t + hhp, vbSrcCopy ' copy Lower Left qtr
BitBlt f4.hDC, 0, 0, hwp, hhp, hDC, l + hwp, t + hhp, vbSrcCopy ' copy Lower Right qtr
ReleaseDC hwnd, hDC ' release the DC (important)
Form1.Hide ' hide orig form
f1.Show: f2.Show: f3.Show: f4.Show ' bring in the clones
For i = 0 To Form1.Left Step tppx ' do something to them - fly apart for ex.
With f1: .Move .Left - tppx, .Top - tppy: End With
With f2: .Move .Left + tppx, .Top - tppy: End With
With f3: .Move .Left - tppx, .Top + tppy: End With
With f4: .Move .Left + tppx, .Top + tppy: End With
DoEvents
Next
Unload f1: Unload f2: Unload f3: Unload f4
End Sub